Skip to content

Work on adding show options to code list pop up - #1379

Open
Crabcyborg wants to merge 36 commits into
masterfrom
work_on_adding_show_options_to_code_list_popup
Open

Work on adding show options to code list pop up#1379
Crabcyborg wants to merge 36 commits into
masterfrom
work_on_adding_show_options_to_code_list_popup

Conversation

@Crabcyborg

@Crabcyborg Crabcyborg commented Nov 17, 2023

Copy link
Copy Markdown
Contributor

Related update https://github.com/Strategy11/formidable-pro/pull/4573 (merged)

Newer related update https://github.com/Strategy11/formidable-pro/pull/6549

TODO

  • Add show=label options for fields with options as well.
image

Test procedure

  1. Create a form and add a Text field, Name field and an option field like Dropdown field.
  2. For the Dropdown field, change one of the labels to a number, like 10 for example.
  3. For the option fields select 'Use separate values' option.
  4. Go to the Text field options and under Advanced > Default Value click on the Calculation tab.
  5. Click on the three dots to trigger the field shortcodes popup and Select 'Text' tab for the calculation.
  6. Confirm that the name field now has three more shortcode options that allows inserting a name part. Ex. show=first
  7. Insert one of the new show shortcodes in the calculation.
  8. Save and Preview the form.
  9. Confirm that everything works as expected.
  10. Turn back to the form builder and check that an additional show=label option is available for the Dropdown field.
  11. Now, change the calculation of the text field to from 'Text' to 'Math' using the tab and insert the show=label shortcode into the calculation and build a number calculation from that adding more operands.
  12. Save and Preview the form.
  13. Confirm that the number calculation works as expected when a number label is selected for the Dropdown field.
image

Summary by CodeRabbit

  • New Features

    • Added shortcode options for individual parts of multi-part fields, including configured first, middle, and last name components.
    • Added support for extensions to provide shortcode parts for other field types.
    • Added field type, label, and styling details to generated shortcode options.
  • Bug Fixes

    • Preserved custom option labels without truncation.
    • Corrected the display order and localization of name-part labels.

@codecov

codecov Bot commented Nov 17, 2023

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (cef6149) 29.26% compared to head (c707b68) 29.27%.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1379   +/-   ##
=========================================
  Coverage     29.26%   29.27%           
  Complexity     7263     7263           
=========================================
  Files           105      105           
  Lines         23937    23937           
=========================================
+ Hits           7006     7007    +1     
+ Misses        16931    16930    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Crabcyborg

Copy link
Copy Markdown
Contributor Author

@AbdiTolesa I was working on adding support for show=first/show=last to the shortcode pop up for name fields to make it easier to insert these special options.

Do you think you'd be able to try taking this over and wrapping it up? I was hoping to also include show="label" for the fields with options that have "Use separate values" enabled as well.

Thank you!

@AbdiTolesa
AbdiTolesa marked this pull request as ready for review September 25, 2024 06:11
@coderabbitai

coderabbitai Bot commented Sep 25, 2024

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Calculation shortcode generation now uses shared helpers. Name-field parts follow the configured layout. PHP and JavaScript expose extension points for additional field parts. Field labels preserve explicitly provided key labels.

Changes

Multipart calculation shortcodes

Layer / File(s) Summary
PHP field-part discovery and wiring
classes/controllers/FrmFormsController.php, classes/controllers/FrmHooksController.php, classes/helpers/FrmFormsHelper.php
The admin controller resolves Name-field parts from name_layout, accepts filtered parts, and inserts shortcode options. The admin hook registers the field-code-tab callback. Explicit key_label values are no longer truncated.
Calculation popup list generation
js/formidable_admin.js, js/src/admin/admin.js
The calculation popup uses shared list-item helpers. Name-field parts are added in layout order, and frm_add_calc_field_shortcodes receives the field, popup, list, and builder callback. Summary lists omit field parts.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CalculationPopup
  participant AdminJS
  participant ExtensionHook
  participant PHPAdmin
  CalculationPopup->>AdminJS: Populate calculation shortcode list
  AdminJS->>AdminJS: Add field and Name-part shortcode items
  AdminJS->>ExtensionHook: Dispatch frm_add_calc_field_shortcodes
  ExtensionHook-->>AdminJS: Add extension-provided shortcode items
  CalculationPopup->>PHPAdmin: Open admin field-code tab
  PHPAdmin-->>CalculationPopup: Insert PHP-generated field-part options
Loading

Possibly related PRs

Suggested labels: action: needs qa

Suggested reviewers: lauramekaj1

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title identifies the main change: adding show options to the code list popup for shortcode insertion.
✨ Finishing Touches 💡 1
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch work_on_adding_show_options_to_code_list_popup
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch work_on_adding_show_options_to_code_list_popup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between aa982e7 and d0e5cc0.

Files selected for processing (1)
  • js/formidable_admin.js (1 hunks)
🔇 Additional comments not posted (2)
js/formidable_admin.js (2)

2905-2907: Ensure browser compatibility

The shouldShowFieldLabelShortcode function uses optional chaining (?.) and includes, which are relatively modern JavaScript features.

Verify that the browsers supported by the Formidable Forms plugin are compatible with these features, or consider providing polyfills or fallback mechanisms for older browsers if necessary.

#!/bin/bash

# Check browser compatibility for optional chaining and includes
ast-grep --lang js --pattern $'
  $$$
  (_) ?. (_)
  $$$
'

ast-grep --lang js --pattern $'
  $$$
  (_).includes(_)  
  $$$
'

2895-2907: Verify compatibility with existing functionality

The new shouldShowFieldLabelShortcode function introduces new logic for determining whether to show the field label shortcode based on the field type and "Use separate values" checkbox state.

Ensure this change is thoroughly tested and does not introduce any regressions or compatibility issues with existing functionality related to calculation fields.

Comment thread js/formidable_admin.js Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Outside diff range and nitpick comments (1)
js/formidable_admin.js (1)

Line range hint 1-3070: Good use of module pattern, but consider breaking it down

The frmAdminBuildJS function implements the module pattern, which is a good practice for encapsulation and organizing code. It creates a closure that contains private functions and variables, while returning an object with public methods and properties. This approach helps in maintaining a clean global namespace and controlling access to internal functionality.

However, the function is quite large and contains many nested functions and variables. Consider breaking this down into smaller, more focused modules or sub-modules. This could improve readability, maintainability, and make it easier to test individual components.

Here's a high-level suggestion for refactoring:

  1. Identify logical groupings of functionality (e.g., form building, settings, export/import).
  2. Create separate modules for each group.
  3. Use ES6 modules or a similar system to manage dependencies between these modules.
  4. Maintain a main module that initializes and coordinates these sub-modules.

This approach would make the code more modular and easier to maintain in the long run.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d6b8a36 and cdafa45.

📒 Files selected for processing (1)
  • js/formidable_admin.js (1 hunks)

Comment thread js/formidable_admin.js Outdated
Comment thread js/formidable_admin.js Outdated
Comment thread js/formidable_admin.js Outdated
@AbdiTolesa
AbdiTolesa requested a review from truongwp October 1, 2024 06:05
Comment thread js/formidable_admin.js Outdated
Comment thread js/formidable_admin.js Outdated
@AbdiTolesa
AbdiTolesa requested a review from truongwp October 3, 2024 07:04

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 8d1c7f5 and f80ffde.

📒 Files selected for processing (1)
  • js/formidable_admin.js (1 hunks)
🧰 Additional context used
🪛 Biome
js/formidable_admin.js

[error] 2867-2868: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (2)
js/formidable_admin.js (2)

2893-2912: Looks good! The new function adds useful functionality.

The maybeAddNamePartShortcodes function is well-structured and adds the ability to insert [nameFieldId show=first], [nameFieldId show=middle] and [nameFieldId show=last] shortcodes to the calculation popup for name fields.

It uses Object.entries and forEach to efficiently loop through the name parts and their labels, and calls addCalcFieldLiToList to add the shortcode <li> elements.

The function is also properly scoped to only run for 'name' field types.


2937-2959: Looks good! The new function improves code modularity.

The new addCalcFieldLiToList function encapsulates the logic for constructing and appending the field shortcode <li> elements to the calculation popup.

It takes the necessary parameters and uses them to build the <a> and <li> elements with the appropriate classes and attributes.

Extracting this logic into a separate function improves code modularity and reusability. The function is also well-documented with JSDoc comments explaining the parameters and return value.

Comment thread js/formidable_admin.js Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🔭 Outside diff range comments (1)
js/formidable_admin.js (1)

2967-2987: 🛠️ Refactor suggestion

Add error handling for JSON parse

The getExcludeArray function parses JSON without error handling.

Add try/catch block around JSON.parse:

- const exclude = JSON.parse(box.getElementsByClassName('frm_code_list')[0].getAttribute('data-exclude'));
+ let exclude = [];
+ try {
+   const excludeAttr = box.getElementsByClassName('frm_code_list')[0].getAttribute('data-exclude');
+   exclude = excludeAttr ? JSON.parse(excludeAttr) : [];
+ } catch (e) {
+   console.error('Error parsing exclude data:', e);
+ }
♻️ Duplicate comments (1)
js/formidable_admin.js (1)

2929-2931: 🛠️ Refactor suggestion

Fix potential undefined return in shouldShowFieldLabelShortcode

The optional chaining operator could return undefined instead of a boolean.

Add an explicit boolean conversion:

- return [ 'radio', 'checkbox', 'dropdown' ].includes( fieldType ) && document.getElementById( `separate_value_${fieldId}` )?.checked;
+ return [ 'radio', 'checkbox', 'dropdown' ].includes( fieldType ) && !! document.getElementById( `separate_value_${fieldId}` )?.checked;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3ca1927 and 7da58a6.

📒 Files selected for processing (1)
  • js/formidable_admin.js (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
js/formidable_admin.js

[error] 2872-2873: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Cypress
🔇 Additional comments (3)
js/formidable_admin.js (3)

2877-2884: LGTM: Proper field list handling

The field list generation and shortcode support check is implemented correctly. The code properly checks for the data-supportsShowShortcodes attribute before adding additional shortcode options.


2898-2917: LGTM: Well-structured name field shortcode handling

The maybeAddNamePartShortcodes function is well-implemented with:

  • Clear type checking
  • Proper field ID validation
  • Localized labels using __()
  • Clean iteration over name parts

2942-2965: LGTM: Well-structured list item creation

The addCalcFieldLiToList function follows best practices:

  • Uses template literals for string interpolation
  • Properly escapes HTML content
  • Uses semantic HTML elements
  • Includes proper data attributes

Comment thread js/formidable_admin.js Outdated
@Crabcyborg

Copy link
Copy Markdown
Contributor Author

@AbdiTolesa Sorry I let this PR get so old.

We've updated the admin JS now so it's in a different admin.js file, and this file that's being changed is minified now.

So we'll need to move these changes into the new file.

Could you help with that?

Thank you!

@AbdiTolesa

Copy link
Copy Markdown
Contributor

So we'll need to move these changes into the new file.

Could you help with that?

@Crabcyborg I have moved the changes to the source js files both in this PR and https://github.com/Strategy11/formidable-pro/pull/5394

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (4)
js/src/admin/admin.js (4)

3050-3065: Feature flag truthiness can misfire; make it explicitly boolean

dataset.supportsShowShortcodes is a string and any non-empty value (including "0") is truthy. Prefer a presence or explicit boolean parse to avoid accidental enabling.

-const supportsShowShortcodes = document.getElementById( 'new_fields' ).dataset.supportsShowShortcodes;
+const newFieldsEl = document.getElementById( 'new_fields' );
+const supportsShowShortcodes = newFieldsEl?.hasAttribute( 'data-supports-show-shortcodes' ) &&
+  (newFieldsEl.dataset.supportsShowShortcodes === '' ||
+   /^(1|true|yes)$/i.test( newFieldsEl.dataset.supportsShowShortcodes ));

3113-3145: Minor UI polish: add spacing and accessible label to shortcode items

Currently the label text is concatenated directly after “[code]” with no space, and the link lacks an accessible label. Add a space node and aria-label to improve readability/AT support.

 function addCalcFieldLiToList( list, fieldId, code, label, fieldType ) {
   const anchor = a( {
     className: 'frm_insert_code',
     children: [
       span( {
         text: '[' + code + ']'
       } ),
-      document.createTextNode( label )
+      document.createTextNode( ' ' ),
+      document.createTextNode( label )
     ],
     data: {
       code
-    }
+    },
+    ariaLabel: label + ' shortcode ' + '[' + code + ']'
   } );

3068-3097: Scope OK; consider reflecting actual Name subparts to avoid dangling options

Nice addition. If practical, hide parts not enabled in the Name field’s current layout (e.g., no Middle) to reduce confusion in the popup.

Please confirm if the Name layout setting is available in DOM (eg, a per-field dropdown). If so, I can wire a small check to only add present parts.


3068-3097: Doc nit: replace “@SInCE x.x” with the release version

Update the JSDoc @since tags to the actual version used in this release.

Also applies to: 3099-3112, 3113-3145

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7da58a6 and 20367ef.

📒 Files selected for processing (1)
  • js/src/admin/admin.js (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
js/src/admin/admin.js (1)
js/admin/dom.js (5)
  • __ (4-4)
  • label (366-372)
  • label (740-740)
  • anchor (710-710)
  • a (27-33)

Comment thread js/src/admin/admin.js
Comment thread js/src/admin/admin.js Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
js/src/admin/admin.js (1)

3096-3109: Dropdowns won’t show “label” shortcode — include 'select' in type check

The field type array omits 'select' (used for Dropdowns elsewhere), so [fieldId show=label] never appears for Dropdown fields.

Apply:

-function shouldShowFieldLabelShortcode( fieldType, fieldId ) {
-  return [ 'radio', 'checkbox', 'dropdown' ].includes( fieldType ) && !! document.getElementById( `separate_value_${ fieldId }` )?.checked;
-}
+function shouldShowFieldLabelShortcode( fieldType, fieldId ) {
+  // Support actual Dropdown type ('select'); keep 'dropdown' for safety if referenced elsewhere.
+  return [ 'radio', 'checkbox', 'select', 'dropdown' ].includes( fieldType ) &&
+    !! document.getElementById( `separate_value_${ fieldId }` )?.checked;
+}

Please also confirm this UI‑side check aligns with Pro behavior (comment noted that Pro needs no changes). [Based on past review comments]

🧹 Nitpick comments (3)
js/src/admin/admin.js (3)

3110-3141: Minor UI nit: add spacing between “[code]” and label

Currently renders as “[123]My Field”. Add a leading space to the label text node.

-        document.createTextNode( label )
+        document.createTextNode( ' ' + label )

3064-3095: Name parts: consider hiding “Middle” when not enabled on the field

You always add first/middle/last. If the Name field is configured without a middle part, showing “(Middle)” may confuse. Optional: gate on the field’s current layout/settings (if available) before adding that shortcode. I can draft a DOM check if you confirm where the layout is stored.


3064-3141: Replace @SInCE x.x placeholders

Docblocks use “@SInCE x.x”. Replace with the actual next version tag used in this repo to keep docs accurate.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 20367ef and cb38709.

📒 Files selected for processing (1)
  • js/src/admin/admin.js (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
js/src/admin/admin.js (1)
js/admin/dom.js (5)
  • __ (4-4)
  • label (366-372)
  • label (740-740)
  • anchor (710-710)
  • a (27-33)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: PHP 8 tests in WP trunk
  • GitHub Check: PHP 7.4 tests in WP trunk
  • GitHub Check: Cypress
  • GitHub Check: Run PHP Syntax inspection (8.3)

Comment thread js/src/admin/admin.js
- Added maybeAddAddressPartShortcodes function to support Address field part shortcodes (line1, line2, city, state, zip, country)
- Added function call in field population loop to display Address field parts in calculation popup
- Similar pattern to Name field implementation

Resolves #5825
- Use template literals instead of string concatenation
- Extract addressParts as const variable for better readability
- Add descriptive JSDoc parameter documentation
- Refine function description to be more professional and direct
- Cleaner forEach syntax with consistent formatting
…hortcodes

- Remove hyphens from JSDoc parameter descriptions for consistency with project style
- Align parameter documentation format with standard JSDoc conventions
shervElmi and others added 2 commits December 9, 2025 21:17
- Added wp.hooks.doAction('frm_add_calc_field_shortcodes') hook
- Removed maybeAddAddressPartShortcodes() function (Address fields are Pro-only)
- Allows Pro and other extensions to add custom field part shortcodes
- Well-documented hook with JSDoc for extension developers
…ptions

Add Address field part shortcodes to calculation popup

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (2)
js/src/admin/admin.js (2)

3056-3074: Localize the “(Label)” suffix in label shortcode entry and avoid hard‑coded English

The UI label for the [fieldId show=label] entry is built as fields[ i ].fieldName + ' (Label)', which is not translatable. This should use the existing i18n helpers so the suffix is localized and consistent with the rest of the admin UI.

A minimal change inline with existing patterns:

- if ( shouldShowFieldLabelShortcode( fields[ i ].fieldType, fields[ i ].fieldId ) ) {
-   addCalcFieldLiToList( list, fieldId, fields[ i ].fieldId + ' show=label', fields[ i ].fieldName + ' (Label)', fields[ i ].fieldType );
- }
+ if ( shouldShowFieldLabelShortcode( fields[ i ].fieldType, fields[ i ].fieldId ) ) {
+   addCalcFieldLiToList(
+     list,
+     fieldId,
+     fields[ i ].fieldId + ' show=label',
+     sprintf( __( '%s (Label)', 'formidable' ), fields[ i ].fieldName ),
+     fields[ i ].fieldType
+   );
+ }

This keeps the UX the same while making the suffix properly translatable.


3119-3121: Dropdowns won’t ever show [fieldId show=label] — type check is missing 'select'

shouldShowFieldLabelShortcode only allows ['radio', 'checkbox', 'dropdown']. In this codebase Dropdown fields actually use the type string 'select' elsewhere, so real Dropdown fields will never satisfy this check and their show=label entries won’t appear in the popup.

Recommend broadening the type list so Dropdowns are correctly supported:

-function shouldShowFieldLabelShortcode( fieldType, fieldId ) {
-  return [ 'radio', 'checkbox', 'dropdown' ].includes( fieldType ) && !! document.getElementById( `separate_value_${ fieldId }` )?.checked;
-}
+function shouldShowFieldLabelShortcode( fieldType, fieldId ) {
+  // Support actual Dropdown type ('select'); keep 'dropdown' in case it exists elsewhere.
+  return [ 'radio', 'checkbox', 'select', 'dropdown' ].includes( fieldType ) &&
+    !! document.getElementById( `separate_value_${ fieldId }` )?.checked;
+}

This aligns the new feature with existing field-type conventions and ensures show=label is available for Dropdowns when “Use separate values” is enabled.

🧹 Nitpick comments (3)
js/src/admin/admin.js (3)

3077-3107: Name-part shortcodes helper looks good; consider aligning with actual name layout (optional)

maybeAddNamePartShortcodes cleanly adds [nameFieldId show=first|middle|last] entries and correctly uses __() for the sublabels, which matches the PR intent.

If you want to tighten UX later, you could read the Name field’s configured layout (eg, which parts are enabled) and skip generating entries for disabled parts so you don’t offer shortcodes like show=middle when no middle-name subfield will ever render. That would avoid confusing, non-functional options in the popup.


3132-3155: Helper for calc-field list items is solid; consider minor accessibility polish

addCalcFieldLiToList centralizes the markup for calc-field entries and correctly stores the raw shortcode in a data-code attribute, which makes the new hook API easier to use and keeps the DOM structure consistent.

Two small optional tweaks you might consider:

  • Add an href="#" (or role="button" and tabindex="0") to the <a> so it’s keyboard-focusable and announced as interactive even if JS fails.
  • If you expect add-ons to call this with non-string fieldId, you might document/normalize it to a string to avoid surprising class names.

No blockers here; helper is otherwise well-factored.


3062-3074: Replace @since x.x placeholders before release

The new frm_add_calc_field_shortcodes hook and helper docblocks still use @since x.x. Before tagging a release, these should be updated to the actual version number so downstream developers have accurate version metadata in the public JS API.

Purely documentation/i18n hygiene; no functional impact.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cb38709 and 6b72e5c.

📒 Files selected for processing (1)
  • js/src/admin/admin.js (1 hunks)

@deepsource-io

deepsource-io Bot commented Aug 6, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 70eddfc...56d366e on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

Code Review Summary

Analyzer Status Updated (UTC) Details
PHP Aug 6, 2026 4:37p.m. Review ↗
JavaScript Aug 6, 2026 4:37p.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

@deepsource-io

deepsource-io Bot commented Aug 6, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in e3ee649...be6808a on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

Important

Some issues found as part of this review are outside of the diff in this pull request and aren't shown in the inline review comments due to GitHub's API limitations. You can see those issues on the DeepSource dashboard.

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
PHP Aug 6, 2026 5:03p.m. Review ↗
JavaScript Aug 6, 2026 5:03p.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

Comment thread js/src/admin/admin.js Outdated
addCalcFieldLiToList(
list,
fieldId,
field.fieldId + ' show=' + code,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unexpected string concatenation


In ES2015 (ES6), we can use template literals instead of string concatenation.

Comment thread js/src/admin/admin.js Outdated
list,
fieldId,
field.fieldId + ' show=' + code,
field.fieldName + ' (' + label + ')',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unexpected string concatenation


In ES2015 (ES6), we can use template literals instead of string concatenation.

Comment thread js/src/admin/admin.js Outdated
last: __( 'Last', 'formidable' )
};
// The layout option names the parts in use, in display order, like first_middle_last.
const layout = document.getElementById( 'name_layout_' + nameFieldId )?.value || 'first_last';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unexpected string concatenation


In ES2015 (ES6), we can use template literals instead of string concatenation.

Comment thread js/src/admin/admin.js Outdated
className: 'frm_insert_code',
children: [
span( label ),
span( { className: 'frm-text-sm frm-text-grey-500', text: '[' + code + ']' } )

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unexpected string concatenation


In ES2015 (ES6), we can use template literals instead of string concatenation.

Comment thread js/src/admin/admin.js Outdated
tag(
'li',
{
className: 'frm-field-list-' + fieldId + ' frm-field-list-' + fieldType,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unexpected string concatenation


In ES2015 (ES6), we can use template literals instead of string concatenation.

* @param array $parts Part labels keyed by the show= option value.
* @param stdClass $field The field the parts belong to.
*/
return apply_filters( 'frm_field_parts_for_shortcodes', $parts, $field );

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function apply_filters invoked with 3 parameters, 2 required


The function call is not valid, which will result in a fatal runtime error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants